<template>
  <view>
    <u-navbar :title="title" left-icon="" />
    <view class="mt25rpx p25rpx">
      <u-parse :content="content" />
      <view class="ma mb25rpx w650rpx">
        <u-button type="primary" shape="circle" @click="toLogin">
          已观看条款
        </u-button>
      </view>
    </view>
  </view>
</template>

<script setup lang='ts' name='term-loginTerms'>
import { onLoad } from '@dcloudio/uni-app';
import { getUserAgreement } from '@/api/user';
import { Toast } from '@/utils';

// 用户协议和隐私政策内容
const content = ref<string>('');
const title = ref<string>('');

onLoad((options: any) => {
  title.value = options?.key === 'userAgreement' ? '用户协议' : '隐私政策';
  getUserAgreement({ configKey: options?.key }).then((res) => {
    content.value = res.rows[0].configValue;
  });
});

// 已观看条款
const toLogin = () => {
  Toast('观看完成默认同意本条款');
  setTimeout(() => {
    uni.navigateBack();
  }, 1000);
};
</script>

<style lang='scss' scoped>
</style>
